package com.chixing.day15.INPUT_OUTPUT;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class IODemo {
    public static void main(String[] args) {
        //1.在f:// 创建文件夹 "test1"
        File file = new File("f://workspacetools//CXJY_WORKSPACE//test1");
        file.mkdirs();


        //2.在f:// test1下创建 "hello.txt"
        File file2 = new File("f://workspacetools//CXJY_WORKSPACE//test1//hello.txt");
        try {
            file2.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        //3. 获得文件 hello.txt的文件名
        String filName = "f://workspacetools//CXJY_WORKSPACE//test1//hello.txt";
        File file3 = new File(filName.trim());
        filName = file3.getName();
        System.out.println(filName);


        //4. 获得文件 hello.txt 的全部路径
        System.out.println(file2.getPath());


        //5. 获得文件 hello.txt的父文件夹
        System.out.println(file2.getParent());


        //6. 判断当前的hello.txt是不是文件
        File file6 = new File("f://workspacetools//CXJY_WORKSPACE//test1//hello.txt");
        boolean s1 = file6.isFile();  //文件
        System.out.println(s1);


        //7.  判断当前的 test1 是不是文件夹
        File file7 = new File("f://workspacetools//CXJY_WORKSPACE//test1");
        boolean s2 = file7.isDirectory();  //目录
        System.out.println(s2);


        //8. 获得到 某一个文件夹下面所有的文件
        File dirFire = new File("f://workspacetools//CXJY_WORKSPACE");
        File[] subFiles = dirFire.listFiles();
        for (int i = 0; i < subFiles.length; i++) {
            System.out.println(subFiles[i].getName());
        }


        //9获得到 某一个文件夹下面所有的文件和子文件
        String fiile = "f://workspacetools//CXJY_WORKSPACE";
        File dir1 = new File(fiile);

        List<File> allFiles = new ArrayList<>();


    }
}

